package com.hqbzl.chat.factory;

import java.util.stream.IntStream;

import com.hqbzl.chat.service.GroupSession;
import com.hqbzl.chat.service.Session;
import com.hqbzl.chat.service.UserService;
import com.hqbzl.chat.service.impl.GroupSessionImpl;
import com.hqbzl.chat.service.impl.SessionMemoryImpl;
import com.hqbzl.chat.service.impl.UserServiceImpl;

public class Factory {
	public static UserService userService = Create.createUserService();
	public static GroupSession groupSession = Create.createGroupService();
	public static Session session = Create.createSession();

	static class Create {
		public static UserService createUserService() {
			return new UserServiceImpl();
		}

		public static GroupSession createGroupService() {
			return new GroupSessionImpl();
		}

		public static Session createSession() {
			return new SessionMemoryImpl();
		}
	}

	static class GroupIns {
		public static GroupSession create() {
			return new GroupSessionImpl();
		}
	}

	public static void main(String[] args) {
		IntStream.range(0, 10).forEach(x -> {
			final UserService inst = Factory.userService;
			System.out.println("inst = " + inst);
		});
	}
}
